package com.platform.modules.wallet.take;

import com.platform.common.config.PlatformConfig;
import com.platform.common.enums.YesOrNoEnum;
import com.platform.modules.wallet.service.WalletRedPacketSubService;
import com.platform.modules.wallet.service.WalletTransferService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;


/**
 * @author Longge
 */
@Component
@Slf4j
public class TakeRun {

//    @Autowired
//    private RoomService roomService;
//    @Autowired
//    private RoomPlayService playService;
    @Autowired
    private ApplicationEventPublisher applicationEventPublisher;
//    @Autowired
//    private SysConfigService sysConfigService;
//    @Autowired
//    private Properties properties;
    @Autowired
    private TaskService taskService;

    @PostConstruct
    public void init() {
//        if (PlatformConfig.MASTER.equals(YesOrNoEnum.NO)) return;
//        if (!isEnvironmentPro()){
//            return;
//        }

        //添加延迟播放结束任务
        TransferRefundTask task = new TransferRefundTask(String.valueOf(1), 10 * 1000);
        taskService.addTask(task);

        boolean contains = taskService.contains(new TransferRefundTask(String.valueOf(1), 12 * 1000));
        log.info(contains+"");//true 表示已经存在

//        //TODO 添加所有中断的任务
//        List<RoomPlay> playing = playService.getPlaying();
//        log.info("启动第二步：添加所有中断的任务{}", playing.size());
//
//        for (RoomPlay play : playing) {
//
//            if (LocalDateTime.now().isBefore(play.getEndTime())) {//在结束之前
//
//                applicationEventPublisher.publishEvent(new SongRePlayEvent(play.getRoomId()));
//
//            } else {//已经结束了 触发结束事件
//                applicationEventPublisher.publishEvent(new SongStopEvent(play.getId()));
//            }
//        }

    }

}
